package com.ysy.logistics.controller.oam;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysy.common.resp.ResultData;
import com.ysy.logistics.entities.oam.LoginLog;
import com.ysy.logistics.myannotation.OperateLog;
import com.ysy.logistics.service.oam.LoginLogService;
import com.ysy.logistics.util.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassDescription:
 * @Author:姚斯羽
 * @Create:2025/3/21 9:52
 **/
@Slf4j
@RestController
@RequestMapping(value = "/loginLog",name = "登录日志")
@Tag(name = "登录日志管理",description = "loginLog表的CRUD")
@CrossOrigin
public class LoginLogController {

    @Resource
    private LoginLogService loginLogService;

    @PostMapping(value = "/listByPage")
    @Operation(summary = "分页查询登录日志",description = "分页查询登录日志")
    @OperateLog("查询登录日志")
    public ResultData listByPage(@RequestBody PageInfo<LoginLog> pageInfo) {
        log.debug("分页查询登录日志："+pageInfo);
        return ResultData.success(loginLogService.listByPage(pageInfo));
    }

    @GetMapping(value = "/clear")
    @Operation(summary = "清空日志",description = "清空日志")
    @OperateLog("清空登录日志")
    public ResultData delete() {
        log.debug("删除登录日志：");
        loginLogService.remove(null);
        return ResultData.success();
    }
}
